package com.shuihu.liutang.redis;
/*
 * Help Information
 *
 * Create Date:2017/4/16
 *
 * zhangle
 */

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.Pipeline;

public abstract class BooklistImporter extends AbsFileImporter{

    private static Logger LOG = LoggerFactory.getLogger(BooklistImporter.class);

    String bookId;
    String exp;

    @Override
    protected abstract String getPrefix();

    @Override
    protected void parseLine(String line) {
        int index = line.indexOf("\t");
        if (index < 0) {
            throw new RuntimeException("parse line failure. - " + line);
        }
        bookId = line.substring(0, index);
        exp = line.substring(index + 1);
        LOG.debug("parseline: {}-{}", bookId, exp);
    }

    @Override
    protected String getKey() {
        return bookId;
    }

    @Override
    protected void saveRecord(Pipeline pipelined) {
        LOG.debug("save parames: {}-{}", key, exp);
        pipelined.sadd(key, exp);
    }
}
